package state;

import model.*;


public class OverallPriceCached implements CachedState {
	
	public static OverallPriceCached create (Product product, int overallPrice){
		return new OverallPriceCached(product, overallPrice);
	}

	private Product product;
	private int overallPrice;

	private OverallPriceCached (Product product, int overallPrice){
		this.product = product;
		this.overallPrice = overallPrice;
	}
	
	public Product getProduct() {
		return product;
	}

	
	public int getOverallPrice() {
		return this.overallPrice;
	}

	
	public MaterialList getMaterialList() {
		MaterialList materialList = this.getProduct().calculateMaterialList();
		this.getProduct().setCurrentState(OverallPriceAndMaterialListCached.create(this.getProduct(), materialList, this.getOverallPrice()));
		return materialList;
	}

	
	public void priceChange() {
		this.getProduct().setCurrentState(NothingCached.create(this.getProduct()));
	}

	
	public void structureChange() {
		this.getProduct().setCurrentState(NothingCached.create(this.getProduct()));
	}

	


}
